import { Body, Controller, HttpCode, Post, UseFilters } from '@nestjs/common';
import { Public } from './public.decorator';
import { AuthService } from './auth.service';
import { HttpExceptionFilter } from 'src/exception/http-exception.filter';
import { wrapperResponse } from 'src/utils';

interface ILogin {
    username:string,
    password:string,
}

@Controller('auth')
export class AuthController {
    constructor(
        private authService:AuthService
    ){}

    @Public()
    @HttpCode(200)
    @Post('login')
    @UseFilters(new HttpExceptionFilter)
    login(@Body() params:ILogin) {
        return wrapperResponse(
            this.authService.login(params.username,params.password),
            '登陆成功'
        )
    }
}
